package router

import (
	_ "gin_gorm_oj/docs"
	"gin_gorm_oj/middleware"
	"gin_gorm_oj/service"
	"github.com/gin-gonic/gin"
	swaggerfiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func Router() *gin.Engine {
	r := gin.Default()

	//swager
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))

	//问题
	r.GET("/ping", service.Ping)
	r.GET("/problem-list", service.GetProblemList)
	r.GET("/problem-detail", service.GetProblemDetail)
	r.PUT("/problem-update", service.ProblemUpdate)
	//用户
	r.GET("/user-detail", service.GetUserDetail)
	r.POST("/login", service.Login)
	r.POST("/register", service.Register)
	r.GET("/userPage", service.GetUsersPage)
	//关注
	r.POST("/relation/follow", service.Follow)
	r.GET("/relation/followList", service.FollowList)
	//提交
	r.GET("/submit-list", service.GetSubmitList)
	//排行榜
	r.GET("/rank-list", service.GetRankList)
	//视频
	r.GET("/video/list", service.GetVideoListByAuthor)
	//这个要middleware.AuthAdminCheck(),暂时算了
	r.POST("video/post", service.PostVideo)
	//管理员私有
	r.POST("/problem-create", middleware.AuthAdminCheck(), service.ProblemCreate)
	//分类管理
	r.GET("/category-list", middleware.AuthAdminCheck(), service.GetCategoryList)
	//分类创建
	r.POST("/category-create", middleware.AuthAdminCheck(), service.CategoryCreate)
	//分类删除
	r.DELETE("/category-delete", middleware.AuthAdminCheck(), service.CategoryDelete)
	//分类修改
	r.PUT("/category-update", middleware.AuthAdminCheck(), service.CategoryUpdate)
	//代码提交
	r.POST("/submit", middleware.AuthUserCheck(), service.Submit)

	return r
}
